package com.zl.awesome.current;

/**
 * @Author: zl
 * @Date: 2021/9/28 14:15
 */
public class WaitNotifyInterupt {
   static Object obj = new Object();

    public static void main(String[] args) throws InterruptedException {
        //create thread
        Thread threadA = new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    System.out.println("---begin---");
                    //block current thread
                    synchronized (obj){
                        obj.wait();
                    }
                    System.out.println("---end---");
                }catch (InterruptedException e){
                    e.printStackTrace();
                }
            }
        });
        threadA.start();
        Thread.sleep(1000);
        System.out.println("---begin interrupt threadA---");
        threadA.interrupt();
        System.out.println("---end interrupt threadA---");
    }
}
